package com.card.game.ddz;

import java.util.Collections;
import java.util.Vector;

import com.card.game.BasePlayer;
import com.card.game.Card;
import com.card.user.User;

public class DdzPlayer extends BasePlayer {
	public transient DdzInfo ddzInfo;
	public transient Vector<Card> cards;
	public transient int qiang;
	
	public DdzPlayer(User user) {
		super(user);
		this.ddzInfo = new DdzInfo(user.getPrimaryKey());
	}
	public void initCards(Vector<Card> cards) {
		Collections.sort(cards,new DdzComp());
		this.cards = cards;
		this.ddzInfo.handSize = this.cards.size();
	}
	
	public int getHandSize() {
		return this.cards.size();
	}
	
	public void addDiPai(Vector<Card> card) {
		this.cards.addAll(card);
		Collections.sort(this.cards,new DdzComp());
		this.ddzInfo.handSize = this.cards.size();
	}
	
	public boolean isContains(Vector<Card> delCards) {
		return this.cards.containsAll(delCards);
	}
	
	public void removeCards(Vector<Card> delCards) {
		this.cards.removeAll(delCards);
		this.ddzInfo.handSize = this.cards.size();
	}
	
	public boolean isWin() {
		return this.cards.isEmpty();
	}
	
	public void clear() {
		super.clear();
		if(this.ddzInfo != null) this.ddzInfo.clear();
		if(this.cards != null) this.cards.clear();
	}
	
	@Override
	public void endGame() {
		super.endGame();
		this.cards = null;
		this.ddzInfo.handSize = 0;
		this.ddzInfo.clear();
		this.qiang = 0;
	}
	
}
